package com.yl.project.lvyou.likes.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yl.framework.aspectj.lang.annotation.Log;
import com.yl.framework.aspectj.lang.enums.BusinessType;
import com.yl.project.lvyou.likes.domain.ScenicCommentLikes;
import com.yl.project.lvyou.likes.service.IScenicCommentLikesService;
import com.yl.framework.web.controller.BaseController;
import com.yl.framework.web.domain.AjaxResult;
import com.yl.common.utils.poi.ExcelUtil;
import com.yl.framework.web.page.TableDataInfo;

/**
 * 评论点赞Controller
 * 
 * @author yl
 * @date 2025-03-14
 */
@Controller
@RequestMapping("/lvyou/likes")
public class ScenicCommentLikesController extends BaseController
{
    private String prefix = "scenemanager/likes";

    @Autowired
    private IScenicCommentLikesService scenicCommentLikesService;

    @RequiresPermissions("scenemanager:likes:view")
    @GetMapping()
    public String likes()
    {
        return prefix + "/likes";
    }

    /**
     * 查询评论点赞列表
     */
    @RequiresPermissions("scenemanager:likes:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ScenicCommentLikes scenicCommentLikes)
    {
        startPage();
        List<ScenicCommentLikes> list = scenicCommentLikesService.selectScenicCommentLikesList(scenicCommentLikes);
        return getDataTable(list);
    }

    /**
     * 导出评论点赞列表
     */
    @RequiresPermissions("scenemanager:likes:export")
    @Log(title = "评论点赞", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ScenicCommentLikes scenicCommentLikes)
    {
        List<ScenicCommentLikes> list = scenicCommentLikesService.selectScenicCommentLikesList(scenicCommentLikes);
        ExcelUtil<ScenicCommentLikes> util = new ExcelUtil<ScenicCommentLikes>(ScenicCommentLikes.class);
        return util.exportExcel(list, "likes");
    }

    /**
     * 新增评论点赞
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存评论点赞
     */
    @RequiresPermissions("scenemanager:likes:add")
    @Log(title = "评论点赞", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ScenicCommentLikes scenicCommentLikes)
    {
        return toAjax(scenicCommentLikesService.insertScenicCommentLikes(scenicCommentLikes));
    }

    /**
     * 修改评论点赞
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ScenicCommentLikes scenicCommentLikes = scenicCommentLikesService.selectScenicCommentLikesById(id);
        mmap.put("scenicCommentLikes", scenicCommentLikes);
        return prefix + "/edit";
    }

    /**
     * 修改保存评论点赞
     */
    @RequiresPermissions("scenemanager:likes:edit")
    @Log(title = "评论点赞", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ScenicCommentLikes scenicCommentLikes)
    {
        return toAjax(scenicCommentLikesService.updateScenicCommentLikes(scenicCommentLikes));
    }

    /**
     * 删除评论点赞
     */
    @RequiresPermissions("scenemanager:likes:remove")
    @Log(title = "评论点赞", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(scenicCommentLikesService.deleteScenicCommentLikesByIds(ids));
    }
}
